﻿using Hx.ADSyncPlatform.Infrastructure.Tree;
using SqlSugar;
using System;
using System.Collections.Generic;

namespace Hx.ADSyncPlatform.Entity.Entities
{
    public class Plat_SysPermission : ITreeNode
    {

        [SugarColumn(IsPrimaryKey = true)]
        public Guid PermissionId { get; set; }

        public Guid ParentId { get; set; }

        public int type { get; set; }


        public string Code { get; set; }

        public string Name { get; set; }


        public string DisplayName { get; set; }


        public string Icon { get; set; }

        public int? sort_order { get; set; }

        public string path { get; set; }


        public string Component { get; set; }

        public string Api { get; set; }

        public int IsEnable { get; set; }


        public string Description { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public int visible { get; set; }

        [SugarColumn(IsIgnore = true)]
        public object Id { get => this.PermissionId; set => this.PermissionId = Guid.Parse(value.ToString()); }

        [SugarColumn(IsIgnore = true)]
        public List<ITreeNode> Children { get; set; } = new List<ITreeNode>();

        [SugarColumn(IsIgnore = true)]
        public int Depth { get; set; }

        [SugarColumn(IsIgnore = true)]
        object ITreeNode.ParentId { get => this.ParentId; set => this.ParentId = Guid.Parse(value.ToString()); }


        public void AddChildren(ITreeNode node)
        {
            this.Children.Add(node);
        }
    }
}
